<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$setting=$this->plugin_setting('setting');
$return['adv']=$setting['hdps'];
$return['footernav']=$setting['footernav'];
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	$return['status']=0;
	$postdata=get_postdata();
	if($postdata['keyword']=='juli'){
		paixu($_SESSION['houselist'],'juli','asc');
		$return['status']=1;
		$return['list']=$_SESSION['houselist'];
	}
	if($postdata['keyword']!='juli'){
		if($postdata['keyword'] ){
			$params['title like']='%'.trim($postdata['keyword']).'%';
		}
		$fields=array('id','title','mobile','logo','name','price','junjia','mianji','type','address','lat_lng');
		$orderby='paixu desc';
		$total='';
		$return['list']=pdo_getslice('jy_cmshouse_list',$params,array($pindex,$psize),$total,$fields,'',$orderby);
		
		foreach($return['list'] as &$v){
			$v['lat_lng']=json_decode($v['lat_lng'],true);
			$v['juli']=cfc('tools')->getdistance($postdata['lng'],$postdata['lat'],$v['lat_lng']['lng'],$v['lat_lng']['lat']);
			$v['juli']=intval($v['juli']/1000);
			$_SESSION['juli'][$id]=$v['juli'];
		}
		$_SESSION['houselist']=$return['list'];
	}
	 set_html('title','首页');
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if($id){
		exi('请选择房产','error','index/');
	}
	$return['detail']=pdo_get('jy_cmshouse_list',array('id'=>$id));
	exi($return);
}

?>